Match a word at the beginning

pattern = ‘^w+’

Write a python program that matches a word at the beginning of a string.
import re

def text_match(S):

    pattern = '^\w+'

    if re.search(pattern, S):
        return 'Found a match!'
    else:
        return('Not matched!')

# test
print(text_match("The quick brown fox jumps over the lazy dog."))
print(text_match(" The quick brown fox jumps over the lazy dog."))

Output:

Found a match!
Not matched!